package com.qf;

import com.qf.conf.LoadbalanceRuleConf;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
//指定我们自己的服务,采用我们自定义的负载均衡策
@RibbonClient(value = "ORDER-PROVIDER",configuration = LoadbalanceRuleConf.class)
//开启hystrix的保护功能
@EnableCircuitBreaker
//@RibbonClients
//启用Feign功能
@EnableFeignClients
public class UserConsumerApplication {

    //注入一个RestTemplate对象，实现基于rest风格的远程调用
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(UserConsumerApplication.class, args);
    }

}
